package com.dkd.web.core.config;

import cn.hutool.core.io.file.FileReader;
import org.dromara.x.file.storage.core.FileStorageProperties;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * TODO 这个是代办的，之后改写成配置类的形式。
 */
//@Configuration
public class XFileStorageConfig {

//    @Bean
    public FileStorageProperties fileStorageProperties() {
        FileStorageProperties properties = new FileStorageProperties();
        properties.setDefaultPlatform("aliyun-oss-1");
        properties.setThumbnailSuffix(".min.jpg");

        List<FileStorageProperties.AliyunOssConfig> aliyunOss = new ArrayList<>();
        FileStorageProperties.AliyunOssConfig aliyunOssConfig = new FileStorageProperties.AliyunOssConfig();
        aliyunOssConfig.setPlatform("aliyun-oss-1");
//        aliyunOssConfig.setEnableStorage(true);
        String[] split = new FileReader(new File("dkd-aliyun-accesskey.csv")).readLines().get(1).split(",");
        aliyunOssConfig.setAccessKey(split[0]);
        aliyunOssConfig.setSecretKey(split[1]);
        aliyunOssConfig.setEndPoint("");
        aliyunOssConfig.setBucketName("");
        aliyunOssConfig.setDomain("");
        aliyunOssConfig.setBasePath("/");

        aliyunOss.add(aliyunOssConfig);
        properties.setAliyunOss(aliyunOss);

        return properties;
    }

}
